-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Adding web client testing framework #498
test: Adding web client testing framework #498
Conversation
@@ -113,14 +113,14 @@ impl WebStore { | |||
pub(super) async fn get_account_code( | |||
&self, | |||
root: Digest, | |||
) -> Result<(Vec<Digest>, ModuleAst), StoreError> { | |||
) -> Result<(Vec<u8>, ModuleAst), StoreError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a small note here to any reviewers that this change is in here because this PR #456 modified the way account code procedures are stored in the client and unintentionally broke account storage/retrieval in the web client due to this small detail. Flagging because this small fix seems out of place with the rest of the testing code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something seems a bit out of sync here: get_account_code on next
has a slightly different signature (i.e., it returns AccountCode
struct rather than a tuple as in this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @dagarcia7 and decided to remove from this PR. His work is overlapping with this and we plan on bringing in the account tests later on alongside it.
@@ -6,7 +6,8 @@ use serde::{de::Error, Deserialize, Deserializer, Serialize}; | |||
#[derive(Serialize, Deserialize)] | |||
pub struct AccountCodeIdxdbObject { | |||
pub root: String, | |||
pub procedures: String, | |||
#[serde(deserialize_with = "base64_to_vec_u8_required", default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.github/workflows/test.yml
Outdated
@@ -29,6 +29,8 @@ jobs: | |||
- uses: actions/checkout@main | |||
- name: Install Rust | |||
run: rustup update --no-self-update | |||
- name: Install Node.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the Makefile
changes look good to me, but will probably ask someone on the miden or lambda class team to take a closer look!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth to create a new workflow in the CI that compiles and runs the web integration tests and thus have them run in parallel, decreasing the time taken by the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was debating doing so but wasn't sure if wanted integration testing to be encapsulated to one workflow. I'm onboard though, will set up for next revision
crates/web-client/tsconfig.json
Outdated
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ | ||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ | ||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ | ||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove all of the rules that have been commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove
await testingPage.evaluate(async () => { | ||
const { WebClient } = await import("./index.js"); | ||
// let rpc_url = "http://18.203.155.106:57291"; | ||
let rpc_url = "http://localhost:57291"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in the .github/workflows/test.yaml
, part of the testing infrastructure is to spin up a local miden node. Would be curious to see if we can point set the RPC url to be that of the freshly spun up node? More of question for the miden team, but this makes sense for now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling this out. I had meant to call this out a bit more in code and in general. I'm planning on adding a top level const to at the very least clarify this ports importance with a comment on it being kept in sync.
There's definitely more robust ways to do this that dont involve manually keeping it in sync. We could have the workflow install a toml parser, and then use that parsed value to pass into the .js via the environment, but I'm going to ask the Miden team for input on whether they'd prefer this given it adds some complexity to their github workflow when this port ultimately may never change .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks great. Only feedback here is it might be worth considering separating out the testing utils into separate locations based on what they do? I.e. account utils, transaction utils, note utils, etc. Don't think this will be an infinite file in the worst case, but might just get pretty long. Minor feedback, though, and isn't bad as is right now. Also some of these are unused since we're just adding a few tests to start so up to you on whether to keep, comment out, or delete for the official PR review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its definitely something we have to keep an eye on. If we think the file is going to grow to double its current size (would be ~1000 lines). Then I believe splitting it up now makes sense. Otherwise, I like "monolithic" since this file has to implement some odd patterns that have unavoidable duplication of code to get the web context working correctly. It helps developer experience with copilot code completion and isolates the complexity.
@@ -72,12 +72,10 @@ pub struct SyncNoteResponse { | |||
/// Block header of the block with the first note matching the specified criteria | |||
#[prost(message, optional, tag = "2")] | |||
pub block_header: ::core::option::Option<super::block_header::BlockHeader>, | |||
/// Proof for block header's MMR with respect to the chain tip. | |||
/// Merkle path to verify the block's inclusion in the MMR at the returned `chain_tip`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why these generated files changed. Its conflicting in the auto-merge so will remove the change
…st code per comments
.github/workflows/test.yml
Outdated
@@ -29,6 +29,8 @@ jobs: | |||
- uses: actions/checkout@main | |||
- name: Install Rust | |||
run: rustup update --no-self-update | |||
- name: Install Node.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth to create a new workflow in the CI that compiles and runs the web integration tests and thus have them run in parallel, decreasing the time taken by the CI.
await testingPage.goto(TEST_SERVER); | ||
|
||
// Uncomment below to enable console logging | ||
// testingPage.on("console", (msg) => console.log("PAGE LOG:", msg.text())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding an env var like debug_mode
or similar to enable console logging? I mean something like:
if env.debug_mode {
testingPage.on("console", (msg) => console.log("PAGE LOG:", msg.text()));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I like that. I'll add some info to the README as well
@@ -0,0 +1,75 @@ | |||
# Testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should specify a node version somewhere the supported node
version.
Looks like there is some issue in the process of terminating the http-server, locally it worked fine. But the CI is stuck in that process, we have tried by re-running and the error persisted. The error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested on my machine and it works correctly.
Is there a way to cache some of the generated files to reduce subsequent builds? Right now it takes around 10 minutes to build each time:
Finished `release` profile [optimized] target(s) in 1m 33s
created dist in 12m 58.8s
describe("faucet tests", () => { | ||
it("create a new faucet", async () => { | ||
const result = await createNewFaucet( | ||
"OffChain", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up, the storage mode names will change to "Private" and "Public" when #514 gets merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be planned for a future PR but we should also add tests for all of the other web client functions referenced here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! We have a POC on our branches for adding all tests. There were just some bugs we had to work out before adding them in
I've added what I believe was a missing await that hopefully address it... Was having trouble reproducing on my local, I'll go back to that if it doesnt fix it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too familiar with some of the components of the test harness, but overall code LGTM! Left some minor comments as well.
Additionally, it seems that the new CI job fails with this error:
[!] (plugin rust) Error: Could not load /home/runner/work/miden-client/miden-client/crates/web-client/Cargo.toml (imported by js/wasm.js): info: syncing channel updates for '1.80-x86_64-unknown-linux-gnu'
Not sure what the way to fix it would be (maybe related to available rust versions or targets?), but let me know if I can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of the functions in this file do not seem to be used right now, so I'd remove them from this PR. I'm guessing future tests would use them, and you also mention you have some other tests you are planning on adding later so I don't mind leaving them but it would make future PRs a bit easier to follow if they use code they are adding. Feel free to disregard this comment if the subsequent tests are going to be up for review soon!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we have a follow up PR coming that should add everything.
describe("wallet tests", () => { | ||
it("create a new wallet", async () => { | ||
const result = await createNewWallet("OffChain", false); | ||
|
||
isValidAddress(result); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we were to test that the accounts that the client is tracking (ie, get_accounts()
) contained the new address. Maybe you were planning on this already for future tests but just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that is part of future tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing newline on this file
I've added a new commit that attempts to fix this. Been trying to get a test environment on my local that mirrors the github workflow to avoid repeatedly posting commits for testing, but the replication ability is limited. The newest commit seems to get past the above quoted issue and runs into others mid-test, but I believe those issues were isolated to my local docker container and not related to the workflow itself. |
* test: Adding web client testing framework
* test: Adding web client testing framework
No description provided.